package com.example.mapper.carecommunity;

import com.example.bean.carecommunity.Contract;
import com.example.bean.carecommunity.SafetySystem;
import com.example.bean.carecommunity.SheQujujia;
import com.example.bean.carecommunity.Vo.SafetySystemVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface SafetySystemMapper {
    List<SafetySystem> selectSafety(SafetySystemVo safetyvo);

    @Select("select safety_system.jigou_id from safety_system join rijianzhaoliao on safety_system.rijianjujia_id=rijianzhaoliao.noid")
    List<String> selectNoid();

    @Select("select zj.noid,xiang.zbx_name,xz_liebiao.zhibiao from zhibiao as xiang join  t_basicinformation_message as zj on zj.zhibiao = xiang.noid left join  xz_liebiao on xz_liebiao.noid = zj.xz_liebiao where xiang.leibie = '内部管理信息' and basic_id = #{id}")
    List<Contract> selectZhibiao(String id);

    @Select("select rijianzhaoliao.*,t_basicinformation.jigou_name from rijianzhaoliao left join t_basicinformation on rijianzhaoliao.jigou_id=t_basicinformation.noid where rijianzhaoliao.is_delete=1")
    List<SheQujujia> getRizhaoJujia();

    @Select("select jigou_id,flag from rijianzhaoliao where noid=#{rijianjujiaid}")
    SheQujujia selectJigouId(String rijianjujiaid);

    Integer addSafetySystem(SafetySystem safetySystem);

    @Select("select * from safety_system where noid=#{noid}")
    SafetySystem selectEditSafety(String noid);

    @Update("update safety_system set is_menwei=#{ismenwei},is_anquanyinhuan=#{isanquanyinhuan},is_huanjingwuran=#{ishuanjingwuran},is_liuyang=#{isliuyang},is_guanlibumen=#{isguanlibumen},admname=#{admname},admphone=#{admphone},is_xiaofang=#{isxiaofang},firename=#{firename},firetype=#{firetype},fire_dayprotection=#{firedayprotection},fire_nightprotection=#{firenightprotection},fire_evacuation=#{fireevacuation},emergency=#{emergency},is_xfbiaoshi=#{isxfbiaoshi},update_time=now(),add_name=#{addname} where noid=#{noid}")
    Integer editSafety(SafetySystem safetySystem);

    @Update("update safety_system set is_menwei=#{ismenwei},is_anquanyinhuan=#{isanquanyinhuan},is_huanjingwuran=#{ishuanjingwuran},is_liuyang=#{isliuyang},is_guanlibumen=#{isguanlibumen},admname=#{admname},admphone=#{admphone},is_xiaofang=#{isxiaofang},firename=null,firetype=#{firetype},fire_dayprotection=#{firedayprotection},fire_nightprotection=#{firenightprotection},fire_evacuation=#{fireevacuation},emergency=#{emergency},is_xfbiaoshi=#{isxfbiaoshi},update_time=now(),add_name=#{addname} where noid=#{noid}")
    Integer editSafetyi(SafetySystem safetySystem);

    @Update("update safety_system set is_delete=0 where noid=#{ids}")
    Integer deleteSafety(String index);
}
